<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>管理系统</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  {:widget_st('layui','css')}
  {:widget_st('admin','css')}
  {:widget_st('bootstrap')}
  {:widget_st('jq','js')}
  {:widget_st('viewer')}

</head>
{:do_action('admin_head')}
<body>

<?php $api_domain = config('version.api_domain'); ?>

<div class="layui-fluid">
  <div class="layui-card">
    <div class="layui-card-body">
      <div style="padding-bottom: 10px;">
        {include file="public/show_updatesql_msg"}
          <a class="layui-btn layui-btn-sm layui-bg-orange" href="?status=1">可用模板</a>
<!--          <a class="layui-btn layui-btn-sm layui-bg-orange" href="?status=">全部模板</a>-->
        <a type="button" class="layui-btn layui-btn-sm btn_edit_mr">还原默认模板</a>
        <a type="button" class="layui-btn layui-btn-sm " href="/?theme=-1" target="_blank">访问当前模板</a>

      </div>
      <table class="layui-table">
          <colgroup>
              <col width="120">
              <col>
          </colgroup>
          <thead>
          <tr>
              <th>插件名</th>
              <th>路径名</th>
              <th>版本</th>
              <th>路径</th>
              <th>图片</th>
              <th>操作</th>
          </tr>
          </thead>
          <tbody>
            <?php foreach($list as $k=>$vo){  ?>
              <tr>
                  <td>
                      {$vo['name']}
                      {$vo['version']|default=''}
                  </td>
                  <td>{$vo['plugin_name']}</td>
                  <td>
                    <?php if(isset($vo['soft_key'])){ ?>
                    <img src="{$api_domain}/addons/zf_store_softclientv2.api/get_new_version?site={$client_config['site']}&token=11&soft_id={$vo['soft_id']}&ver={$vo['version']|default=''}&soft_key={$vo['soft_key']}" />
                    <?php } ?>
                  </td>
                  <td>{$vo['path']|default=''}</td>
                  <td style="text-align: center;">
                    <img src="{$vo['pic']}" style="height: 50px;" /> 
                  </td>
                  <td>
                    <?php if(is_dir('./theme/'.$vo['plugin_name']) ){ ?>
                        <a  href="/?theme={$vo['plugin_name']}" target="_blank">查看演示</a>   
                        <span class="flow  "  >
                          <?php if($tpl_name==$vo['plugin_name']){ ?>
                            <a class="layui-btn layui-btn-sm btn_edit layui-btn-primary layui-border-green" style="color:red" item="{$vo['plugin_name']}">
                              <i class="layui-icon layui-icon-rate"></i>默认模板
                            </a>
                            <a class="layui-btn layui-btn-sm  layui-btn-primary layui-border-green" onclick='zfAdminShow("模板配置","{:url('/i_admin')}")' >
                              <i class="layui-icon layui-icon-rate"></i>配置
                            </a>
                          <?php }else{ ?>
                            <a class="layui-btn layui-btn-sm btn_edit  layui-btn-primary layui-border-green" item="{$vo['plugin_name']}" >
                              <i class="layui-icon layui-icon-rate"></i>设为默认模板
                            </a>
                          <?php } ?>
                        </span>
                        <?php if($is_professional_edition){ ?>
                        <?php } ?>
                    <?php }else{ ?>
                      <span style="color: red">代码缺失</span>
                    <?php } ?>
                  </td>
              </tr>
            <?php }  ?> 
          </tbody>
      </table>
      {$page|raw}

    </div>
  </div>
</div>


  {:widget_st('layui','js')}  
  {:widget_st('common','js')}
  <script>
 layui.use(['layer','upload'], function(){
    var $ = layui.$ 
    ,laypage = layui.laypage
    ,layer = layui.layer
    ,element = layui.element
    ,upload = layui.upload;

    
   $('.btn_edit').on("click",function(){
      var value = $(this).attr('item');
      var key = 'zf_tpl_suffix'
      $.ajax({
        type:'post',
        url:"{:url('admin/common/config_edit')}",
        data:{key:key,value:value},
        dataType:'json',
        success:function(res){
          console.log(res)
          if(res.result==1){
            layer.msg(res.msg, {icon: 1});
            layer.close()
            setTimeout(function() {
              window.location.reload();
            }, 2000);
          }else{
            layer.msg(res.msg, {icon: 2});
          }   
        }
      })
   })
   $('.btn_edit_mr').on("click",function(){
      var value = '';
      var key = 'zf_tpl_suffix'
      $.ajax({
        type:'post',
        url:"{:url('admin/common/config_edit')}",
        data:{key:key,value:value},
        dataType:'json',
        success:function(res){
          console.log(res)
          if(res.result==1){
            layer.msg(res.msg, {icon: 1});
            layer.close()
            setTimeout(function() {
              window.location.reload();
            }, 2000);
          }else{
            layer.msg(res.msg, {icon: 2});
          }   
        }
      })
   })


});
  </script>
</body>
</html>
{:do_action('admin_js')}
<script>$('.detail-body').viewer();</script>